package com.esri.core.map;

import android.graphics.Color;
import com.esri.core.geometry.SpatialReference;
import com.esri.core.symbol.TextSymbol;

/* loaded from: classes.dex */
public class GraphicsUtil {
    public static final SpatialReference getSpatialReference(Graphic graphic) {
        if (graphic == null) {
            return null;
        }
        return graphic.spatialReference;
    }

    public static final void updateTextSymbolsText(FeatureSet featureSet) {
        Graphic[] graphics;
        String[] attributeNames;
        if (featureSet == null || (graphics = featureSet.getGraphics()) == null) {
            return;
        }
        for (Graphic graphic : graphics) {
            if (graphic != null && graphic.getSymbol() != null && (graphic.getSymbol() instanceof TextSymbol)) {
                TextSymbol textSymbol = (TextSymbol) graphic.getSymbol();
                if ((textSymbol.getText() == null || textSymbol.getText().trim().length() < 1) && (attributeNames = graphic.getAttributeNames()) != null) {
                    int length = attributeNames.length;
                    int i = 0;
                    while (true) {
                        if (i >= length) {
                            break;
                        }
                        String str = attributeNames[i];
                        if (str == null || !str.equalsIgnoreCase("text")) {
                            i++;
                        } else {
                            Object attributeValue = graphic.getAttributeValue(str);
                            if (attributeValue != null) {
                                textSymbol.setText(attributeValue.toString());
                                graphic.setSymbol(textSymbol);
                            }
                        }
                    }
                }
            }
        }
    }

    public static final Object convertStringFieldValue(String str, String str2, Field[] fieldArr) {
        if (str != null && !str.trim().equals("") && str2 != null && fieldArr != null) {
            for (Field field : fieldArr) {
                if (field.getName().equals(str2)) {
                    int fieldType = field.getFieldType();
                    if (fieldType == 10 || fieldType == 20) {
                        try {
                            return Integer.valueOf(str);
                        } catch (NumberFormatException unused) {
                            return new Integer(Integer.parseInt(str, 16));
                        }
                    } else if (fieldType != 30 && fieldType != 40) {
                        if (fieldType != 50) {
                            if (fieldType == 60) {
                                return str;
                            }
                            if (fieldType != 80) {
                                if (fieldType == 100 || fieldType == 110) {
                                    return str;
                                }
                                return null;
                            }
                        }
                        try {
                            Long.valueOf(str);
                        } catch (NumberFormatException unused2) {
                            return str;
                        }
                    } else {
                        return Double.valueOf(str);
                    }
                }
            }
        }
        return null;
    }

    public static final int colorToAbgr(int i) {
        return Color.red(i) | (Color.alpha(i) << 24) | (Color.blue(i) << 16) | (Color.green(i) << 8);
    }

    public static final int abgrToColor(int i) {
        return Color.argb((i >> 24) & 255, i & 255, (i >> 8) & 255, (i >> 16) & 255);
    }
}
